package cn.base.zuoye1;

public class Code005 {
    public static void main(String[] args) {
        // 打印出(个位+百位)等于(十位+千位)的所有4位数，要求每行打印5个数字。并统计有多少个符合条件的四位数。
        int count = 1;
        int g, s, b, q;
        for (int i = 1000; i <= 9999; i++) {
            g = i % 10;
            s = i / 10 % 10;
            b = i / 100 % 10;
            q = i / 1000;
            if (g + b == s + q) {
                System.out.print(i + " ");
                if (count % 5 == 0) {
                    System.out.println();
                }
                count++;
            }
        }
        System.out.println("一共有" + (count - 1));
    }
}
